const server = require("../../server/server.js");
//index.js
//获取应用实例
const app = getApp()
// console.log(app);

Page({
    data: {
        dot: true,
        autopaly: true,
        time: 5000,
        loops: [],
        products: []
    },
    onLoad: function () {
        this.loadLoopData();
        this.loadProductList();
    },
    loadLoopData: function () {
        server.loadLoopList1()
            //then里第一个回调里的参数是上一个then里第一个回调返回的数据
            .then((data) => {
                this.setData({
                    loops: data
                });
            })
            .catch((error) => {
                console.log(error);
            });
    },
    loadProductList() {
        server.loadProductList1()
            .then((data) => {
                this.setData({
                    products: data.rows
                });
            })
            .catch((error) => {
                console.log(error);
            });
    },
    onPullDownRefresh(){
        this.loadProductList();
    }

})
